package com.flynn.rock.crm.entity.customer;

import com.flynn.rock.enums.customer.CustomerCreateType;
import com.flynn.rock.enums.customer.CustomerOrderStatus;
import com.flynn.rock.enums.customer.CustomerStatus;
import com.flynn.rock.enums.customer.CustomerType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Lob;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Getter
@Setter
@Entity
@Table(name = "crm_customer")
public class CustomerEntity {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "customer_id", nullable = false)
    private Long customerId;

    @Column(name = "customer_code", length = 64)
    private String customerCode;

    @Column(name = "customer_name", length = 64)
    private String customerName;

    @Column(name = "identity_number", length = 64)
    private String identityNumber;

    @Column(name = "gender", length = 6)
    private String gender;

    @Column(name = "age")
    private Integer age;

    @Column(name = "phone", length = 32)
    private String phone;

    @Column(name = "email", length = 64)
    private String email;

    @Column(name = "we_chat", length = 64)
    private String weChat;

    @Lob
    @Column(name = "avatar")
    private String avatar;

    @Column(name = "customer_type", length = 32)
    @Enumerated(EnumType.STRING)
    private CustomerType customerType;

    @Column(name = "customer_address")
    private String customerAddress;

    @Column(name = "customer_rank")
    private Integer customerRank;

    @Column(name = "loan_limit")
    private BigDecimal loanLimit = new BigDecimal("0.00");

    @Column(name = "create_user_id")
    private Long createUserId;

    @Column(name = "create_time")
    private LocalDateTime createTime;

    @Column(name = "update_time")
    private LocalDateTime updateTime;

    @Column(name = "status", length = 32)
    @Enumerated(EnumType.STRING)
    private CustomerStatus status;

    @Column(name = "remark", length = 64)
    private String remark;

    @Column(name = "follow_up_user_id")
    private Long followUpUserId;

    @Column(name = "follow_up_user_name")
    private String followUpUserName;

    @Enumerated(EnumType.STRING)
    @Column(name = "follow_up_status", length = 64)
    private CustomerOrderStatus followUpStatus;

    @Column(name = "last_follow_up_time")
    private LocalDateTime lastFollowUpTime;

    @Enumerated(EnumType.STRING)
    @Column(name = "create_type", length = 64)
    private CustomerCreateType createType = CustomerCreateType.manually_create;
}